function total_count() {
    showTableAndEcharts();
    stopColor();
    isFlag = true;
    $.ajax({
        method:"POST",
        url:"findTotalCount",
        success:function (data) {

            $("#tip").html("<h3>网站总访问量的统计</h3>");
            $("#echart-tip").html("<h3>网站总访问量的图表</h3>");

            //添加图表对应的容器
            $("#dataEcharts div:gt(0)").remove();
            $("#dataEcharts").append('<div id="totalType" class="col-sm-6"></div>');
            $("#dataEcharts").append('<div id="totalPUV" class="col-sm-6" style="padding-left: 150px"></div>');

            //重置表头
            $("#head-tr").empty();
            $("#head-tr").append("<th>ID</th><th>浏览量</th><th>加入购物车量</th><th>购买量</th><th>总量</th><th>用户访问量</th>");

            //重置表的数据
            $("tbody").empty();
            var jsonArr = JSON.parse(data);

            $.each(jsonArr, function (index, sexCount) {

                $("tbody").append("<tr class='info'><td>" + sexCount.id + "</td><td>" + sexCount.viewCount +
                    "</td><td>" + sexCount.cartCount + "</td><td>" + sexCount.parchaseCount + "</td><td>" + sexCount.totalCount +
                    "</td><td>" + sexCount.uvCount + "</td></tr>");

            });

            $("tbody tr").on("mouseenter", this, function() {
                color = $(this).attr("class");
                $(this).removeClass(color);
                $(this).addClass("success");
            });
            $("tbody tr").on("mouseleave", this, function() {
                $(this).removeClass("success");
                $(this).addClass(color);
            });

            //传递数据
            createPie(jsonArr);
            //传递数据
            createBar(jsonArr);
        }
    });

}

function createPie(jsonArr) {

    var viewCount = 0;
    var cartCount = 0;
    var parchaseCount = 0;
    $.each(jsonArr, function (index, totalCount) {
        viewCount = totalCount.viewCount;
        cartCount = totalCount.cartCount;
        parchaseCount = totalCount.parchaseCount;
    });

    var totalTypeData = [{
        value: viewCount,
        name: 'view'
    }, {
        value: cartCount,
        name: 'cart'
    }, {
        value: parchaseCount,
        name: 'parchase'
    }];
    var sexTotal = echarts.init(document.getElementById("totalType"));
    var option = {
        title: {
            text: '网站不同操作访问量的统计',
            left: 'center'
        },
        tooltip: {
            trigger: 'item'
        },
        legend: {
            orient: 'vertical',
            left: 'right'
        },
        series: [{
            type: 'pie',
            data: totalTypeData
        }]
    };
    sexTotal.setOption(option);
    sexTotal.resize({
        width: 400,
        height: 350
    });
}

function createBar(jsonArr) {
    console.log(jsonArr);
    var totalPUV = echarts.init(document.getElementById("totalPUV"));
    var option = {
        tooltip: {
            trigger: 'item'
        },
        xAxis: {},
        yAxis: {
            data: ["PV", "UV"]
        },
        series: {
            type: 'bar',
            id: 'sales',
            data: [jsonArr[0].totalCount, jsonArr[0].uvCount]
        }
    };

    totalPUV.setOption(option);
    totalPUV.resize({
        width: 400,
        height: 350
    });
}